import HorizontalPlatform
import IntervalWorkingDevice
import pygame
image1=pygame.image.load("shockbeambarrier.jpg")
image1.set_colorkey((137,44,75))
image2=pygame.image.load("shockbeambarrier_.jpg")
image2.set_colorkey((137,44,75))

class ShockBeamBarrier(IntervalWorkingDevice.IntervalWorkingDevice, HorizontalPlatform.HorizontalPlatform):
	def __init__(self,pos=(0,0),image=image1,image_=image2,intervals=(25,35),c_interval=1,c_time=1,off=False):
		HorizontalPlatform.HorizontalPlatform.__init__(self,pos=pos,image=image)
		IntervalWorkingDevice.IntervalWorkingDevice.__init__(self,intervals=intervals,c_interval=c_interval,c_time=c_time,off=off)
		self.image_=image_
	def reaction_up(self,objecto):
		x1=objecto.intermediate_x(self.upperSide())
		if objecto.isAlive() and self.cur_interval==1 and objecto.electricDamageTaken(10)>0:
			objecto.reposition(x1,self.upperSide())
			objecto.putInStun(1)
			self.boundY(objecto,False)
	def reaction_down(self,objecto):
		x2=objecto.intermediate_x(self.lowerSide()-objecto.getHeight())
		if objecto.isAlive()  and self.cur_interval==1 and objecto.electricDamageTaken(10)>0:
			objecto.rebound(x2,self.lowerSide()-objecto.getHeight())
			objecto.putInStun(1)
			self.boundY(objecto,False)
	def hasFallenOff_y(self,objecto):
		if self.cur_interval==0:
			self.unbound(objecto)
		elif objecto.electricDamageTaken(10)>0:
			objecto.putInStun(1)
	def drawingInformation(self):
		if self.cur_interval==1:
			return self.pos,self.image
		return self.pos,self.image_
